import {Component} from '@angular/core'
import {Toast,ToastOptions} from '@ionic-native/toast'
import {MyApp} from "../../../app/app.component";

@Component({
  selector: 'page-native-toast',
  templateUrl: 'toast.html'
})
export class NativeToastPage {

  constructor(public toast: Toast) {

  }

  show(option:ToastOptions={
    message: 'default message',
    duration: 1500,
    position: 'center',
    styling:{}
  }) {
    if (MyApp.isCordova) {
      this.toast.hide()
      this.toast.showWithOptions(option).subscribe();
    }
  }

  showToast(type,message='提示信息'){
    this.toast.hide()
    this.toast[type](message).subscribe((toast)=>{
      console.log(toast)
    });
  }

  showToastWithStyle(){
    this.toast.hide()
    this.show({
      message: 'default message',
      duration: 3000,
      position: 'bottom',
      styling: {
        backgroundColor:'#000000',
        textColor: '#ffffff',
        cornerRadius: 10
      }
    })
  }
}
